package com.hm.oper_monitor;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;

import org.springframework.stereotype.Component;

import com.hm.common.util.SpringUtil;
import com.hm.oper_monitor.bean.ResourcesManager;
import com.hm.oper_monitor.constants.Constants;
import com.hm.oper_monitor.init.Init;

@Component
@SuppressWarnings("serial")
public class OperMonitor extends JFrame {
	public static JPanel bgPanel;
	ResourcesManager rm;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
//		EventQueue.invokeLater(new Runnable() {
//			public void run() {
//				try {
//					SpringUtil.getBean(OperMonitor.class);
//				} catch (Exception e) {
//					e.printStackTrace();
//				}
//			}
//		});
	}

	private void init() {
		rm = SpringUtil.getBean(ResourcesManager.class);
		rm.initScreenSize();
		initBackgroundPanel();
		if (rm.getScreenViewProp().getScreenViewModel() == Constants.SCREEN_VIEW_MODEL_SYSTEM){
			this.setBounds(0, 0, rm.getScreenViewProp().getScreenWidth(), rm.getScreenViewProp().getScreenHeight());
		} else {
			this.setBounds(rm.getScreenViewProp().getScreenX(), rm.getScreenViewProp().getScreenY(), rm.getScreenViewProp().getScreenWidth(), rm.getScreenViewProp().getScreenHeight());
		}
		
//		this.setUndecorated(true);
		this.setContentPane(bgPanel);
		this.setTitle("运维监控系统");
		this.setVisible(true);
	}
	
	/**
	 * 给Frame增加背景面板
	 * @return
	 */
	public JPanel initBackgroundPanel() {
		bgPanel = new JPanel();
		bgPanel.setLayout(new BorderLayout());
		bgPanel.setBounds(0, 0, rm.getScreenViewProp().getScreenWidth(), rm.getScreenViewProp().getScreenHeight());
		return bgPanel;
	}

	/**
	 * Create the frame.
	 */
	public OperMonitor() {
		this.init();
		Init init = new Init(bgPanel);
		Thread t = new Thread(init);
		t.start();
	}
	
}
